<?php  if ( ! defined('APPPATH')) exit('No direct script access allowed');

load_core('model');

class Photo_model extends Model {
	
	protected $TB_PHOTO = 'photo';
	protected $TB_PHOTO_META = 'photo_meta';

	public function __construct() {
		parent::__construct();
	}

	public function get_all_photos() {
		return $this->db->query("SELECT id, uid, file, title, upload_time
			FROM {$this->TB_PHOTO} ORDER BY id DESC")->result();
	}

	public function get_all_photos_count() {
		$query = $this->db->query("SELECT COUNT(id) FROM {$this->TB_PHOTO}");
		return current($query->row());
	}

	public function get_photos($offset=0, $limit=50) {
		return $this->db->query("SELECT id, uid, file, title, upload_time 
			FROM {$this->TB_PHOTO} ORDER BY id DESC LIMIT $offset, $limit")
			->result();
	}

}